package controller;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import model.College;
import model.Teacher;
import model.Users;
import view.Main_Frame;
import view.PanelDASboard;
import view.PanelExport;
import view.PanelGroupList;
import view.PanelTeacherList;
import view.PanelHolder;
import view.PanelSelector;
import view.PanelUserList;
import view.loginPanel;

public class PanelSwitcher implements ActionListener {

	public void actionPerformed(ActionEvent a) {

		@SuppressWarnings("unused")
		PanelSelector panelselector = PanelSelector.getInstance();
		// Main_Frame mf =Main_Frame.getInstance();
		PanelHolder hold = PanelHolder.getInstance();

		if (a.getActionCommand().equals("DASboard")) {
			hold.remove(hold.getComponentAt(0, 31));
			hold.add(PanelDASboard.getInstance());
			hold.repaint();
			hold.validate();

		}
		if (a.getActionCommand().equals("Export")) {
			hold.remove(hold.getComponentAt(0, 31));
			hold.add(PanelExport.getInstance());
			hold.repaint();
			hold.validate();

		}
		if (a.getActionCommand().equals("docent")) {

			hold.remove(hold.getComponentAt(0, 31));
			hold.add(PanelTeacherList.getInstance());
			hold.repaint();
			hold.validate();
		}

		if (a.getActionCommand().equals("klas")) {

			hold.remove(hold.getComponentAt(0, 31));
			hold.add(PanelGroupList.getInstance());
			hold.repaint();
			hold.validate();

		}
		if (a.getActionCommand().equals("gebruiker")) {

			hold.remove(hold.getComponentAt(0, 31));
			hold.add(PanelUserList.getInstance());
			hold.repaint();
			hold.validate();
		}

		if (a.getActionCommand().equals("logout")) {
			Main_Frame mf = Main_Frame.getInstance();
			mf.remove(hold);
			mf.add(loginPanel.getInstance());
			mf.repaint();
		}
		if (a.getActionCommand().equals("refresh")) {
			College.getInstance().getAllactiveTeachers();
			College.getInstance().getAllGroups();
			Users.getInstance().getAllUsers();
			Teacher.getInstance().getAllAbsences();
			Teacher.getInstance().getAllAbsencesToday();
			Teacher.getInstance().getAllAbsencesWeek();

		}

	}
}
